<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('表格传值给父页面')" />
</head>
<body class="gray-bg">
<input type="hidden" id="rowIds">
<div class="container-div">
    <div class="row">
<!--        <table class="table table-bordered">-->
<!--        <div class="col-sm-12 select-table table-striped">-->
            <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "system/ticketorder/"; // ctx + "demo/table";
    // var datas = [[${@dict.getType('sys_normal_disable')}]];

    //layui-layer-title
    //此处即为修改modal的标题
    // modal.find('.modal-title').text('New message to ' + recipient)
    // $(this).find('.layui-layer-title').val()

//layui-layer-title
//     var current_title = $(document).attr('title');
    console.log("页面标题="+ $(".layui-layer-title").text()  +"@");
    console.log("页面标题="+ $(".layui-layer-title").html()  +"@");
    console.log("页面标题="+ $(".layui-layer-title").val()  +"@");

    $(function() {
        var options = {
            url: prefix + "/showtimeseatlist/17",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pageSize : 100000,
            columns: [
                {
                    // field: 'column8',
                    // title: '第8列',
                    // align: 'center',
                    formatter: function(value, row, index) {
                        return "第"+(index+1)+ "排";
                    }
                },
                {
                    field : 'column1',
                    title : '第1列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 1, row.column1);
                    },
                    formatter: function(value, row, index) {
//                        return JSON.stringify(row);
//                        return "["+value+"]" + (index * 10 + row);
                     //   console.log('row='+JSON.stringify(row));
                     //    return index * 10 + 1;
                        return formatSeat(index * 10 + 1, row.column1);
                    }
                },
                {
                    field : 'column2',
                    title : '第2列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 2, row.column2);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 2, row.column2);
                    }
                },
                {
                    field : 'column3',
                    title : '第3列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 3, row.column3);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 3, row.column3);
                    }
                },
                {
                    field : 'column4',
                    title : '第4列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 4, row.column4);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 4, row.column4);
                    }
                },
                {
                    field : 'column5',
                    title : '第5列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 5, row.column5);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 5, row.column5);
                    }
                },
                {
                    field : 'column6',
                    title : '第6列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 6, row.column6);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 6, row.column6);
                    }
                },
                {
                    field : 'column7',
                    title : '第7列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 7, row.column7);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 7, row.column7);
                    }
                },
                {
                    field: 'column8',
                    title: '第8列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 8, row.column8);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 8, row.column8);
                    }
                },
                {
                    field: 'column9',
                    title: '第9列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 9, row.column9);
                    },
                    formatter: function(value, row, index) {
                        return formatSeat(index * 10 + 9, row.column9);
                    }
                },
                {
                    field: 'column10',
                    title: '第10列',
                    align: 'center',
                    cellStyle:function(value,row,index){
                        return formatSeatCSS(index * 10 + 10, row.column10);
                    },
                    // formatter: function(value, row, index) {
                    //     // var actions = [];
                    //     // actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑'+value+'</a> ');
                    //     // // actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
                    //     // return actions.join('');
                    // },
                    formatter: function(value, row, index) {
                        // return value;
                        return formatSeat(index * 10 + 10, row.column10);
                    }
                }]
        };
        $.table.init(options);
    });

    /* 添加用户-选择用户-提交(子页面调用父页面形式) */
    function submitHandler(index, layero) {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.close();
        // 父页面的方法
        // activeWindow().selectUsers();
        // 父页面的变量
        activeWindow().$('#userids').html('我是通过方式一来的：' + rows.join());
    }

    /* 添加用户-选择用户-提交(回调形式-父页面调用子页面) */
    function getSelections() {
        return $.table.selectFirstColumns();
    }

    $("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
        var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
        var rowIds = $.table.affectedRowIds(rows);
        $("#rowIds").val(rowIds);
    });
    
    
    function formatSeat(seatNumber, state) {
        // return seatNumber +":"+state;
        if(state == -1)
            return "";
        return '<span style="color: white;">' + ( seatNumber ) + '</span>';
    }

    function formatSeatCSS(seatNumber, state) {
        // return seatNumber +":"+state;
        if(state == 1)//已出售
        {
            return {css:{"background-color":"#ed5565"}};
        }
        else if(state == 2)//可出售
        {
            return {css:{"background-color":"#23c6c8"}};
        }else//没有该座位
            {
                return {css:{"background-color":"#ddd"}};
        }
    }
</script>
</body>
</html>